package com.easy.service.impl;

import com.easy.bean.Equipment;
import com.easy.mapper.EquipmentDao;
import com.easy.service.EquipmentService;
import com.easy.util.Page;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class EquipmentServiceImpl implements EquipmentService {

    @Autowired
    EquipmentDao equipmentDao;

    @Override
    public Equipment add(Equipment equipment) {
        equipmentDao.add(equipment);
        return equipmentDao.one(equipment.getId());
    }

    @Override
    public int del(Integer id) {
        return equipmentDao.del(id);
    }

    @Override
    public Equipment edit(Equipment equipment) {
        equipmentDao.edit(equipment);
        return equipmentDao.one(equipment.getId());
    }

    @Override
    public List<Equipment> all(String name, String status) {
        return equipmentDao.all(name, status);
    }

    @Override
    public Equipment one(Integer id) {
        return equipmentDao.one(id);
    }

    @Override
    public void page(Page page, Equipment equipment) {
        int count = equipmentDao.pageCount(equipment);
        List<Equipment> data = equipmentDao.page(page, equipment);
        page.setCount(count);
        page.setData(data);
    }
}